﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web.Mvc.Html;
using System.Web.Routing;

namespace FB.Mvc.Extensions
{
    public static class ActionLinkExtension
    {
        public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, bool Visible)
        {
            string controllerName = (string)htmlHelper.ViewContext.RouteData.GetRequiredString("controller");
            return ActionLinkExtension.ActionLink(htmlHelper, linkText, actionName, controllerName, new RouteValueDictionary(), new RouteValueDictionary(), Visible);
        }

        public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, object routeValues, bool Visible)
        {
            string controllerName = (string)htmlHelper.ViewContext.RouteData.GetRequiredString("controller");
            return ActionLinkExtension.ActionLink(htmlHelper, linkText, actionName, controllerName, new RouteValueDictionary(routeValues), new RouteValueDictionary(), Visible);
        }

        public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, RouteValueDictionary routeValues, bool Visible)
        {
            string controllerName = (string)htmlHelper.ViewContext.RouteData.GetRequiredString("controller");
            return ActionLinkExtension.ActionLink(htmlHelper, linkText, actionName, controllerName, routeValues, new RouteValueDictionary(), Visible);
        }

        public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, bool Visible)
        {
            return ActionLinkExtension.ActionLink(htmlHelper, linkText, actionName, controllerName, new RouteValueDictionary(), new RouteValueDictionary(), Visible);
        }

        public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, object routeValues, object htmlAttributes, bool Visible)
        {
            string controllerName = (string)htmlHelper.ViewContext.RouteData.GetRequiredString("controller");
            return ActionLinkExtension.ActionLink(htmlHelper, linkText, actionName, controllerName, new RouteValueDictionary(routeValues), new RouteValueDictionary(htmlAttributes), Visible);
        }

        public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, object routeValues, object htmlAttributes, bool Visible)
        {
            return ActionLinkExtension.ActionLink(htmlHelper, linkText, actionName, controllerName, new RouteValueDictionary(routeValues), new RouteValueDictionary(htmlAttributes), Visible);
        }

        public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes, bool Visible)
        {
            return (Visible) ? LinkExtensions.ActionLink(htmlHelper, linkText, actionName, controllerName, routeValues, htmlAttributes) : new MvcHtmlString(string.Empty);
        }

    }
}
